package com.erp.utils;

import java.io.Serializable;
import java.util.*;

/**
 * Description: TeamProject
 * Created by ${ZhangZhenJun}on 2019/1/11.
 */
public class Msg implements Serializable {

    /**
     * 状态码 0:正常
     */
    private Integer code;

    /**
     * 非0状态码 错误信息
     * 当状态码为0时 Msg必须为空
     */
    private String msg;

    /**
     * 数据总条数
     */
    private long count;

    /**
     * 数据集合
     */
    private List<?> data = new ArrayList<>();

    private Map<String,Object> map = new HashMap<>();

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<?> getData() {
        return data;
    }

    public void setData(List<?> data) {
        this.data = data;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    @Override
    public String toString() {
        return "Msg{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", count=" + count +
                ", data=" + data +
                ", map=" + map +
                '}';
    }


    static Msg success(long count,List<?> list,Map<String,Object> map){
        Msg msg=new Msg();
        msg.setCode(0);
        msg.setMsg("");
        msg.setData(list);
        msg.setCount(count);
        msg.setMap(map);
        return msg;
    }


    static Msg error(Integer code,String str){
        Msg msg=new Msg();
        msg.setCode(code);
        msg.setMsg(str);
        return msg;
    }

}
